package com.kwz.engine.graphics;

import com.kwz.common.designpatterns.UnknownObject;

/**
 * <p>
 *                  Classe de base pour les couleurs 
 * </p> 
 *
 * @author Ccr
 */
public class KwzColor extends UnknownObject implements IColor {

    // Membres internes
    protected int                   alpha;
    protected int                   red;
    protected int                   green;
    protected int                   blue;
    
    /**
     * 
     */
    public KwzColor(){
        this(0,0,0,0);
    }
    
    /**
     * @param red
     * @param green
     * @param blue
     */
    public KwzColor(int red,int green,int blue){
        this(red,green,blue,255);
    }
    
    /**
     * @param red
     * @param green
     * @param blue
     * @param alpha
     */
    public KwzColor(int red,int green,int blue,int alpha){
        this.red = red;
        this.blue = blue;
        this.green = green;
        this.alpha = alpha;
    }
    
    // ------------------------ IColor -------------------
    /* (non-Javadoc)
     * @see com.kwz.engine.graphics.IColor#getAlpha()
     */
    public int getAlpha() {
        return alpha;
    }

    /* (non-Javadoc)
     * @see com.kwz.engine.graphics.IColor#getBlue()
     */
    public int getBlue() {
        return blue;
    }

    /* (non-Javadoc)
     * @see com.kwz.engine.graphics.IColor#getGreen()
     */
    public int getGreen() {
        return green;
    }

    /* (non-Javadoc)
     * @see com.kwz.engine.graphics.IColor#getRed()
     */
    public int getRed() {
        return red;
    }

    /* (non-Javadoc)
     * @see com.kwz.engine.graphics.IColor#setAlpha(int)
     */
    public void setAlpha(int alpha) {
        this.alpha = alpha;
    }

    /* (non-Javadoc)
     * @see com.kwz.engine.graphics.IColor#setBlue(int)
     */
    public void setBlue(int blue) {
        this.blue = blue;
    }

    /* (non-Javadoc)
     * @see com.kwz.engine.graphics.IColor#setGreen(int)
     */
    public void setGreen(int green) {
        this.green = green;
    }

    /* (non-Javadoc)
     * @see com.kwz.engine.graphics.IColor#setRed(int)
     */
    public void setRed(int red) {
        this.red = red;
    }

    /* (non-Javadoc)
     * @see com.kwz.engine.graphics.IColor#setRGB(int, int, int)
     */
    public void setRGB(int red, int green, int blue) {
        this.red = red;
        this.blue = blue;
        this.green = green;
    }

    /* (non-Javadoc)
     * @see com.kwz.engine.graphics.IColor#setRGBA(int, int, int, int)
     */
    public void setRGBA(int red, int green, int blue, int alpha) {
        setRGB(red, green, blue);
        this.alpha = alpha;
    }

    // ---------------------- Surcharges ----------------------------
    /* (non-Javadoc)
     * @see java.lang.Object#clone()
     */
    @Override
    protected Object clone() throws CloneNotSupportedException {
        return new KwzColor(red,green,blue,alpha);
    }

    /* (non-Javadoc)
     * @see java.lang.Object#equals(java.lang.Object)
     */
    @Override
    public boolean equals(Object obj) {
        boolean result;
        if (obj instanceof IColor){
            IColor c = (IColor)obj;
            result = (this.red == c.getRed() && this.green == c.getGreen() && this.red == c.getRed() && this.alpha == c.getAlpha());
        }
        else {
            result = super.equals(obj);
        }
        return result;
    }
    
    

}
